#!/bin/sh
# $Id: load,v 0.1 2011/08/01 06:19:49 saeedM Exp 
#	krawsk : kernel raw socket example Module Loader script	
#
#	Author: SaeedM <saeed.tx@gmail.com> , Aug-2011
#
# 
# 	This program is free software; you can redistribute it and/or
#       modify it under the terms of the GNU General Public License
#       as published by the Free Software Foundation; either version
#       2 of the License, or (at your option) any later version
#

module="krawsk"
device="krawsk"
mode="777"

# Group: since distributions do it differently, look for wheel or use staff
if grep -q '^staff:' /etc/group; then
    group="staff"
else
    group="wheel"
fi

# invoke insmod with all arguments we got
# and use a pathname, as insmod doesn't look in . by default
/sbin/insmod ./$module.ko $* || exit 1

# retrieve major number
major=250
#$(awk "\\$2==\"$module\" {print \\$1}" /proc/devices)

# Remove stale nodes and replace them, then give gid and perms
# Usually the script is shorter, it's scull that has several devices in it.

rm -f /dev/${device}
mknod /dev/${device} c $major 0
chgrp $group /dev/${device} 
chmod $mode  /dev/${device}







